<?php

class IRobotWebUser extends CWebUser {

    protected $_model;

    function isAdmin() {
        $user = $this->loadUser();
        if ($user)
            if ($user->account_type == 0) {
                return true;
            }
        return false;
    }

    function isSubAdmin() {
        $user = $this->loadUser();
        if ($user)
            if ($user->account_type == -1) {
                return true;
            }
        return false;
    }

    protected function loadUser() {
        if ($this->_model === null) {
            $this->_model = UserAccount::model()->findByPk(Yii::app()->user->id);
        }
        return $this->_model;
    }

}

?>
